package plus.xj17520.org.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import plus.xj17520.basic.domain.AjaxResult;
import plus.xj17520.basic.util.SMSUtil;
import plus.xj17520.org.service.IUserService;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @projectName: pethome_xj
 * @package: plus.xj17520.org.controller
 * @className: UserController
 * @author: XiaoJue
 * @description: TODO
 * @date: 2022/4/2 11:32
 * @version: 1.0
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService userService;


    //    后台校验手机号是否正确
//    @GetMapping("checkphone/{phoneNum}")
//    public AjaxResult sendCode(@PathVariable String phoneNum) {
//        userService.findPhone(phoneNum);
//
//
//    }

//    发送验证码
    @GetMapping("sendmobilecode/{phoneNum}")
    public Map sendCode(HttpServletRequest request, @PathVariable String phoneNum) {
        HashMap<String, Object> map = new HashMap<>();
        if (phoneNum != null && !phoneNum.equals("")) {
            String s = SMSUtil.sendSMS(request, phoneNum);
            map.put("message", "验证码发送成功！");
        } else {
            map.put("message", "验证码发送失败！");
        }
        return map;
    }
}
